using System;
using System.Globalization;
using System.Reflection;
using System.Web.UI;

namespace Sedna.Core.Controller.Configurations
{
	/// <summary>
	/// Summary description for DecimalStringDataParser.
	/// </summary>
	public class DecimalStringDataParser: NumberStringDataParser
	{
		protected int scale=4;

		public int Scale
		{
			set { scale = value; }
		}

		public DecimalStringDataParser()
		{
			NumberType=typeof(Decimal);
		}

		public override object UnsafeTranslate(Control control, object value, Type targetType)
		{
			object parsedValue=base.UnsafeTranslate(control, value, targetType);
			if (!(parsedValue is Decimal))
			{
				return parsedValue;	
			}

			return Decimal.Round((Decimal)parsedValue, scale);
		}
	}
}
